home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1173 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.4 KB  |  46 lines

  1. Path: news.iag.net!news
  2. From: jatmon@iag.net (John R Buchan)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Problem with sscanf on DEC Alpha
  5. Date: 11 Jan 1996 23:00:42 GMT
  6. Organization: Internet Access Group, Orlando, Florida
  7. Message-ID: <4d44qq$j32@news.iag.net>
  8. References: <4d3f0c$mfq@colossus.holonet.net>
  9. NNTP-Posting-Host: pm2-orl27.iag.net
  10. X-Newsreader: WinVN 0.99.7
  11.  
  12. In article <4d3f0c$mfq@colossus.holonet.net>, mitch@news.mdli.com says...
  13. >
  14. >I'm having a problem with a line in my program:
  15. >
  16. >  sscanf( sInputLine, "%3d%3d%10.4f%10.4f", &iAtom1, 
  17. >    &iAtom2, &(F3D->r3DV1), &(F3D->r3DV2) );
  18. >
  19. >F3D is a pointer to struct and the struct has double members
  20. >r3DV1 and r3DV2.  
  21.  
  22. I'm assuming that you mean something like:
  23.  
  24. struct 
  25.    {
  26.    double r3DV1, r3DV2;
  27.    } *F3D;
  28.  
  29. Your problem is that you are telling scanf to read and store a float,
  30. then passing the address of a double.  Try:
  31.  
  32.   sscanf( sInputLine, "%3d%3d%10.4lf%10.4lf", &iAtom1, 
  33.     &iAtom2, &(F3D->r3DV1), &(F3D->r3DV2) );
  34.  
  35. The 'l' (lower case 'L') tells scanf to read and store a double. A 'L'
  36. would indicate a long double.
  37.  
  38. The c.l.c faq (Frequently Asked Question) list explains (Q12.13)this and many
  39. other common questions.  It ia available for anonymous ftp from rtfm.mit.edu
  40. /pub/usenet/comp.lang.c.
  41.  
  42. -- 
  43. John R Buchan           -:|:-     Looking for that elusive FAQ?  ftp to:
  44. jatmon@mail.iag.net     -:|:-     rtfm.mit.edu /pub/usenet-by-group/....
  45.  
  46.